<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>组织信息同步接口配置</title>
		<%@include file="/WEB-INF/ibnms/common/jqgrid.jsp"%>
		<%@ include file="/WEB-INF/ibnms/common/formValidation.jsp"%>
		<jsp:include page="/WEB-INF/ibnms/common/configinclude.jsp"></jsp:include>
		<script language="javascript">

        </script>
	</head>

	<body>
		<div class="form-wrapper">
	    	<div class="form-title">
	       		 <span class="ttcorner"></span>
	             <h3>
	                <span class="text">组织信息同步接口配置</span>
	             </h3>
	        </div>
	        <div class="box-in">
	        	 <form id="editForm" action="<s:url action="saveWebHooks"/>" method="post">
					<input type="hidden" name="webHooks.ID" id="webHooks.ID"  value="${webHooks.ID}">
					<table id="table1" border="0" cellspacing="0" cellpadding="0" class="table-03">
						<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap width="100px">
				         		系统名称：
					         </td>
					         <td>
					         	<input type="text" name="webHooks.NAME" id="webHooks.NAME" class="validate[required,maxSize,50]" value='${webHooks.NAME}' /><font color="red">*</font>
					         </td>
				   		</tr>
				   		<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap>
				         		接口地址：
					         </td>
                            <td>
                                <input type="text" name="webHooks.URL" id="webHooks.URL" class="validate[required,maxSize,200]" value='${webHooks.URL}' size='80'/><font color="red">*</font>
                            </td>
				   		</tr>
				   		<tr>
				         	 <td class="monitor_bg1" height="13" align ="right" nowrap>
				         		选择同步信息：
					         </td>
					         <td>
					         	<label><input type='checkbox' name='webHooks.USER_EVENDS' value='1'>用户信息</label>
                                     <br><br>
                                 <label><input type='checkbox' name='webHooks.DEPT_EVENDS' value='1'>部门信息</label>
                                    <br><br>
                                 <label><input type='checkbox' name='webHooks.ROLE_EVENDS' value='1'>角色信息</label>
                                     <br><br>
                                 <label><input type='checkbox' name='webHooks.WORKGROUP_EVENDS' value='1'>工作组信息</label>
                             </td>
				   		</tr>
					</table>
					<div class="block03">
						<input type="button" class="btn-style02" id="btn-save" value="保存" />
						&nbsp;&nbsp;
						<input type="button" class="btn-style02" value="重置" onclick="resetForm()" />
						<input type="button" class="btn-style02" value="返回" onclick="back()" />
					</div>
	        	 </form>
	        </div>
        </div>
	</body>
	<script language="javascript">
        $(function(){
            if('${param.op}'=='edit'){
                if('${webHooks.USER_EVENDS}' == '1'){
                    $("[name='webHooks.USER_EVENDS']").attr("checked","checked");
                }
                if('${webHooks.DEPT_EVENDS}' == '1'){
                    $("[name='webHooks.DEPT_EVENDS']").attr("checked","checked");
                }
                if('${webHooks.ROLE_EVENDS}' == '1'){
                    $("[name='webHooks.ROLE_EVENDS']").attr("checked","checked");
                }
                if('${webHooks.WORKGROUP_EVENDS}' == '1'){
                    $("[name='webHooks.WORKGROUP_EVENDS']").attr("checked","checked");
                }
            }
        })
		function back(){
			window.location.href="<s:url action='webHooksList' namespace='/'/>";
		}
		function resetForm(){
			$('#editForm')[0].reset();
		}
		
        $("#btn-save").click(function() {
            var webHooks={};
            webHooks.URL = $("[id='webHooks.URL']").val();
            webHooks.NAME = $("[id='webHooks.NAME']").val();
            webHooks.ID = $("[id='webHooks.ID']").val();
            webHooks.USER_EVENDS = $("[name='webHooks.USER_EVENDS']:checked").val();
            webHooks.DEPT_EVENDS = $("[name='webHooks.DEPT_EVENDS']:checked").val();
            webHooks.ROLE_EVENDS = $("[name='webHooks.ROLE_EVENDS']:checked").val();
            webHooks.WORKGROUP_EVENDS = $("[name='webHooks.WORKGROUP_EVENDS']:checked").val();
            var array=[];
            $.each($("[name='webHooks.syncKind']:checked")||[],function(k,v){
                array.push($(this).val());
            })
            webHooks.OPERATE = array.join(",");
            $.ajax({
                url: '<s:url action="saveWebHooks" />',
                type: 'POST',
                data: {webHooks: webHooks},
                success: function (data) {
                    alert("保存成功");
                    window.location.href="<s:url action='webHooksList' namespace='/'/>";
                },
                error: function (xhr) {
                    if (confirm("保存失败，是否查看错误日志？")) {
                        window.open().document.write(xhr.responseText);
                    }
                }
            })
		});



		
    </script>
</html>
